home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / utility / fbuild14.zip / ADDTOPM1.TXT < prev    next >
Text File  |  1992-01-28  |  3KB  |  87 lines

  1. ' AddToProgMan, for Word for Windows v1.1
  2. '
  3. ' Robert M. Ryan, 28 January 1992, v1.4
  4. '
  5. ' This is a Word for Windows macro which allows you to add the current document to the
  6. ' specified Program Manager Group.
  7. '
  8. ' To install this macro, do the following:
  9. '
  10. '    1. open this document in Word for Windows.
  11. '    2. select (i.e. highlight) the entire document and select Edit, Copy (Ctrl-Ins)
  12. '    3. Select "Edit..." from the "Macro" menu
  13. '    4. Type in a macro name (e.g. "AddToProgMan")
  14. '    5. Push the "Ok" button
  15. '    6. Paste the macro in the buffer.
  16. '    7. Close the window, saving changes.
  17. '    8. If you want, assign it to a key
  18. '    9. When you exit, make sure to save changes to the global glossary
  19. '
  20.  
  21. Sub MAIN
  22.     Begin Dialog UserDialog 410, 170
  23.     Text 10, 6, 231, 13, "Add Item to Program Manager:"
  24.     Text 47, 25, 73, 13, "Filename:"
  25.     Text 47, 45, 40, 13, "Title:"
  26.     Text 47, 66, 52, 13, "Group:"
  27.     Text 47, 88, 40, 13, "Icon:"
  28.     CheckBox 135, 112, 139, 16, "Save Changes", .Save
  29.     OKButton 105, 135, 88, 21
  30.     CancelButton 211, 135, 88, 21
  31.     TextBox 135, 22, 262, 18, .FName$
  32.     TextBox 135, 43, 262, 18, .Title$
  33.     TextBox 135, 64, 262, 18, .Group$
  34.     TextBox 135, 85, 263, 18, .Icon$
  35.     End Dialog
  36.  
  37.     n$ = LCase$(FileName$(0))
  38.     m$ = n$
  39.     q$ = Chr$(34)
  40.  
  41.     ' remove path from filename
  42.     For i = 1 To Len(n$)
  43.         If Mid$(n$, i, 1) = "\" Then m$ = Right$(n$, Len(n$) - i)
  44.     Next i
  45.  
  46.     ' remove extension from filename
  47.     i = InStr(m$, ".")
  48.     If i > 0 Then m$ = Left$(m$, i - 1)
  49.  
  50.     Dim dlg As UserDialog
  51.  
  52.     dlg.Group$ = GetProfileString$("Add To Group")
  53.     If dlg.Group$ = "" Then dlg.Group$ = "Documents"
  54.     dlg.Icon$ = GetProfileString$("Add Using Icon")
  55.     If dlg.Icon$ = "" Then dlg.Icon$ = "\win\icons\doc.ico"
  56.     dlg.FName$ = LCase$(FileName$(0))
  57.     dlg.Title$ = m$
  58.  
  59.     On Error Goto NoDialog
  60.     Dialog dlg
  61.     On Error Goto 0
  62.  
  63.     ChanNum = DDEInitiate("PROGMAN", "PROGMAN")
  64.     If ChanNum = 0 Then
  65.         MsgBox "Unable to initiate DDE conversation with ProgMan", "Error"
  66.         return
  67.     Else
  68.         window$ = WindowName$()
  69.         AppActivate "Program Manager", 1
  70.         DDEExecute ChanNum, "[CreateGroup(" + dlg.Group$ + ",6)]" ' create if necessary
  71.         DDEExecute ChanNum, "[ShowGroup(" + dlg.Group$ + ",6)]"    ' minimize
  72.         DDEExecute ChanNum, "[ShowGroup(" + dlg.Group$ + ",1)]"    ' restore
  73.         cmd$ = "[AddItem(" + dlg.FName$ + "," + q$ + dlg.Title$ + q$ + "," + dlg.Icon$ + ")]"
  74.         DDEExecute ChanNum, cmd$                ' add file to group
  75.         DDEExecute ChanNum, "[ShowGroup(" + dlg.Group$ + ",6)]"    ' minimize
  76.         DDETerminate ChanNum                    ' terminate discussion
  77.         Activate window$
  78.     End If
  79.     If dlg.Save Then
  80.         SetProfileString "Add To Group", dlg.Group$
  81.         SetProfileString "Add Using Icon", dlg.Icon$
  82.     End If
  83.  
  84. NoDialog:
  85.  
  86. End Sub
  87.